<?php
class Offer extends AppModel {
	var $name = 'Offer';
	var $useDbConfig = 'lex';
	var $displayField = 'id';
	//The Associations below have been created with all possible keys, those that are not needed can be removed

// 	var $virtualFields = array(
// 		    'icon' => 'Image.name'
// 	);

	public $actsAs = array('Searchable');
	public $filterArgs = array(
		array('name' => 'typ_id', 'type' => 'value'),
		array('name' => 'transakcja_id', 'type' => 'value'),
		array('name' => 'cena_od', 'type' => 'value'),
		array('name' => 'cena_do', 'type' => 'value'),
		array('name' => 'powierzchnia_od', 'type' => 'value'),
		array('name' => 'powierzchnia_do', 'type' => 'value')
	);
	
	var $belongsTo = array(
		'Typ' => array(
			'className' => 'Typ',
			'foreignKey' => 'typ_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Transakcja' => array(
			'className' => 'Transakcja',
			'foreignKey' => 'transakcja_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);

	var $hasAndBelongsToMany = array(
		'Image' => array(
			'className' => 'Image',
			'joinTable' => 'offers_images',
			'foreignKey' => 'offer_id',
			'associationForeignKey' => 'image_id',
			'unique' => true,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
			'deleteQuery' => '',
			'insertQuery' => ''
		)
	);

}
